package com.dliu.javacore.enumFeature;

import lombok.Getter;

/**
 * enum枚举值还可以拥有各自的内部方法！
 * @author yanglei
 * date 2021/3/26 9:40
 */
@Getter
public enum InnerMethod {
    DOG("狗"){
        @Override
        public void voice() {
            System.out.println("汪汪汪~");
        }

        @Override
        public String eat() {
            return "骨头";
        }
    },
    CAT("猫"){
        @Override
        public void voice() {
            System.out.println("喵喵喵~");
        }

        @Override
        public String eat() {
            return "猫粮";
        }
    },
    SHEEP("羊"){
        @Override
        public void voice() {
            System.out.println("咩咩咩~");
        }

        @Override
        public String eat() {
            return "草";
        }
    },
    ;

    private final String name;

    InnerMethod(String name) {
        this.name = name;
    }

    public abstract void voice();
    public abstract String eat();

    public static void main(String[] args) {
        InnerMethod.DOG.voice();
        System.out.println(InnerMethod.CAT.eat());
    }
}
